package com.gugee.ins.common.dal.mapper.brand;


import com.gugee.common.mapper.GugeeMapper;
import com.gugee.ins.common.model.mysql.brand.InsRelBrandMedia;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface InsRelBrandMediaMapper extends GugeeMapper<InsRelBrandMedia> {

    @Delete("delete from ins_rel_brand_media where bid = #{bid}")
    void deleteByBid(@Param("bid") int bid);

    @Insert({"<script>",
            "insert into ins_rel_brand_media (shortcode,owner_uid,is_video,product_type,taken_time,score," +
                    "bid,update_time,is_ad,product_tag_type,is_sponsored,is_brand_account," +
                    "media_id,like_count,comment_count,er,video_view_count,video_play_count) VALUES",
            "<foreach collection = 'insRelBrandMedias' item='insRelBrandMedia' separator=','>",
            " (#{insRelBrandMedia.shortcode},#{insRelBrandMedia.ownerUid},#{insRelBrandMedia.isVideo},#{insRelBrandMedia.productType}," +
                    "#{insRelBrandMedia.takenTime},#{insRelBrandMedia.score},#{insRelBrandMedia.bid},#{insRelBrandMedia.updateTime}," +
                    "#{insRelBrandMedia.isAd},#{insRelBrandMedia.productTagType},#{insRelBrandMedia.isSponsored},#{insRelBrandMedia.isBrandAccount}," +
                    "#{insRelBrandMedia.mediaId},#{insRelBrandMedia.likeCount},#{insRelBrandMedia.commentCount},#{insRelBrandMedia.er}," +
                    "#{insRelBrandMedia.videoViewCount},#{insRelBrandMedia.videoPlayCount})",
            "</foreach>",
    "</script>"})
    void insertBatch(@Param("insRelBrandMedias")List<InsRelBrandMedia> insRelBrandMedias);
}